package com.qf.controller;

import com.qf.dto.OwnerDto;
import com.qf.entity.Owner;
import com.qf.result.ResponseResult;
import com.qf.service.OwnerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/owner")
@Api(tags = "业主管理接口")
public class OwnerController {

    @Resource
    private OwnerService ownerService;

    //获取业主列表
    @ApiOperation(value = "获得业主列表")
    @GetMapping("/getOwnerList")
    public ResponseResult getOwnerList(String ownerName) {
        return ownerService.getOwnerList(ownerName);
    }

    //增加业主
    @ApiOperation(value = "新增业主信息")
    @PostMapping("/addOwner")
    public ResponseResult addOwner(@Valid @RequestBody OwnerDto ownerDto) {
        return ownerService.addOwner(ownerDto);
    }

    //删除业主
    @ApiOperation(value = "删除业主信息")
    @DeleteMapping("/deleteOwner/{id}")
    public ResponseResult deleteOwner(@PathVariable("id") Integer id) {
        return ownerService.deleteOwner(id);
    }

    //修改业主信息
    @ApiOperation(value = "修改业主信息")
    @PutMapping("/updateOwner")
    public ResponseResult updateOwner(@Valid @RequestBody OwnerDto ownerDto) {
        return ownerService.updateOwner(ownerDto);
    }

}
